using Microsoft.AspNetCore.Mvc;
using star_questionnair.Models;
using star_questionnair.Services;

namespace star_questionnair.Controllers;
[Route("differenceSortQuestionAnalysis")]
[ApiController]

public class DifferenceSortQuestionAnalysisController : ControllerBase
{
        private readonly IDifferenceSortQuestionAnalysisService _differenceSortQuestionAnalysisService;

        public DifferenceSortQuestionAnalysisController(IDifferenceSortQuestionAnalysisService differenceSortQuestionAnalysisService)
        {
            _differenceSortQuestionAnalysisService = differenceSortQuestionAnalysisService;
        }

        // Gender Difference Analysis - Endpoint 1
        [HttpGet("gender1/{questionId}")]
        public async Task<ActionResult<Dictionary<bool, Dictionary<string, double>>>> GetGenderDifferenceAsync(int questionId)
        {
            var result = await _differenceSortQuestionAnalysisService.GetGenderDifferenceAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // Age Difference Analysis - Endpoint 1
        [HttpGet("age1/{questionId}")]
        public async Task<ActionResult<Dictionary<string, Dictionary<string, double>>>> GetAgeDifferenceAsync(int questionId)
        {
            var result = await _differenceSortQuestionAnalysisService.GetAgeDifferenceAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // Enterprise Difference Analysis - Endpoint 1
        [HttpGet("enterprise1/{questionId}")]
        public async Task<ActionResult<Dictionary<string, Dictionary<string, double>>>> GetEnterpriseDifferenceAsync(int questionId)
        {
            var result = await _differenceSortQuestionAnalysisService.GetEnterpriseDifferenceAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // Role Difference Analysis - Endpoint 1
        [HttpGet("role1/{questionId}")]
        public async Task<ActionResult<Dictionary<string, Dictionary<string, double>>>> GetRoleDifferenceAsync(int questionId)
        {
            var result = await _differenceSortQuestionAnalysisService.GetRoleDifferenceAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // Gender Difference Analysis - Endpoint 2
        [HttpGet("gender2/{questionId}")]
        public async Task<ActionResult<Dictionary<bool, Dictionary<string, List<double>>>>> GetGenderDifferenceAnalysisAsync(int questionId)
        {
            var result = await _differenceSortQuestionAnalysisService.GetGenderDifferenceAnalysisAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // Age Difference Analysis - Endpoint 2
        [HttpGet("age2/{questionId}")]
        public async Task<ActionResult<Dictionary<string, Dictionary<string, List<double>>>>> GetAgeDifferenceAnalysisAsync(int questionId)
        {
            var result = await _differenceSortQuestionAnalysisService.GetAgeDifferenceAnalysisAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // Enterprise Difference Analysis - Endpoint 2
        [HttpGet("enterprise2/{questionId}")]
        public async Task<ActionResult<Dictionary<string, Dictionary<string, List<double>>>>> GetEnterpriseDifferenceAnalysisAsync(int questionId)
        {
            var result = await _differenceSortQuestionAnalysisService.GetEnterpriseDifferenceAnalysisAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }

        // Role Difference Analysis - Endpoint 2
        [HttpGet("role2/{questionId}")]
        public async Task<ActionResult<Dictionary<string, Dictionary<string, List<double>>>>> GetRoleDifferenceAnalysisAsync(int questionId)
        {
            var result = await _differenceSortQuestionAnalysisService.GetRoleDifferenceAnalysisAsync(questionId);
            if (result != null)
                return Ok(new { success = true, data = result });
            return Ok(new { message = "No words found." });
        }
}